
import { DefaultLayout, GraphNode } from "@/js/components/GraphNode"
import { GraphView } from "@/js/components/GraphView"
import { InputLinkNodeAny, InputLinkNodeBoolean, InputLinkNodeFlow } from "@/js/components/InputLinkNode"

export class PrintLog extends GraphNode{
    layout?: DefaultLayout
    load(){
        super.load()

        const layout = new this.DefaultLayout(this, this.graphView as GraphView)
        this.layout = layout
        this.appendChild(layout.container)

        const targetEntry = new InputLinkNodeAny(this, this.graphView as GraphView, {
            name: "target",
            desc: '目标',
            model: "entry",
        })
        layout.main?.left.appendChild(targetEntry)
    }
}

PrintLog.parser =  ({node,toNode}: any)=>{
    const next = toNode(node.outputs.output[0], 'enter')
    return `console.log(${toNode(node.enters.target[0], 'output') || node.userData.enters.target});${next}`
}